#include "StdAfx.h"
#include ".\triggerareahash.h"
#include "Player.h"

__IMPL_POOL( TriggerAreaHash )

TriggerAreaHash::TriggerAreaHash(void)
{
	m_AreaEnteredPlayerHash.Initialize( MAX_PARTYMEMBER_NUM*3 );
}

TriggerAreaHash::~TriggerAreaHash(void)
{

}

VOID TriggerAreaHash::Init()
{
	m_AreaEnteredPlayerHash.RemoveAll();
}


DWORD TriggerAreaHash::FindPlayer(DWORD UserKey)
{
	return m_AreaEnteredPlayerHash.GetData( UserKey );
}
VOID TriggerAreaHash::LeaveArea(DWORD UserKey)
{
	ASSERT( NULL != m_AreaEnteredPlayerHash.GetData(UserKey) );
	m_AreaEnteredPlayerHash.Remove( UserKey );
}
VOID TriggerAreaHash::EnterArea(DWORD UserKey)
{
	ASSERT( NULL == m_AreaEnteredPlayerHash.GetData(UserKey) );
	if( NULL != m_AreaEnteredPlayerHash.GetData(UserKey) ) return;
	m_AreaEnteredPlayerHash.Add( UserKey, UserKey );
}
/*
BOOL TriggerAreaHash::CheckValidPlayer()
{
	BOOL rt = TRUE;
	for( A_ITERATOR itr = m_AreaEnteredPlayerHash.begin() ; itr != m_AreaEnteredPlayerHash.end() ; ++itr )
	{
		Player * pPlayer = PlayerManager::Instance()->FindPlayer(*itr);
		if( !pPlayer )
		{
			m_AreaEnteredPlayerHash.erase(itr);
			rt = FALSE;
		}
	}
	return rt;
}
*/